package per.chenxin.util.tcp.http;

import org.apache.commons.codec.binary.Base64;

public class Entity {
	String proxyHost = null;

	int proxyPort = 0;

	String username = null;

	String password = null;

	String authorization = null;

	public Entity(String proxyHost, int proxyPort, String username,
			String password, String authorization) {
		this.proxyHost = proxyHost;
		this.proxyPort = proxyPort;
		this.username = username;
		this.password = password;
		this.authorization = authorization;
	}

	public Entity(String proxyHost, int proxyPort, String authorization) {
		this.proxyHost = proxyHost;
		this.proxyPort = proxyPort;
		this.authorization = authorization;
	}

	public String getProxyHost() {
		return proxyHost;
	}

	public void setProxyHost(String proxyHost) {
		this.proxyHost = proxyHost;
	}

	public int getProxyPort() {
		return proxyPort;
	}

	public void setProxyPort(int proxyPort) {
		this.proxyPort = proxyPort;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getAuthorization() {
		if (authorization != null)
			return authorization;

		if (username == null || password == null)
			return null;

		return new String(Base64.encodeBase64((username + ":" + password)
				.getBytes()));

	}

	public void setAuthorization(String authorization) {
		this.authorization = authorization;
	}

}